import {defineStore} from 'pinia'
import persistLocalstorage from "@/common/persistLocalstorage";

interface PlayTimes {
  newOrder: 3,
  newPreOrder: 1,
  newPickupTask: 1,
  newReviewTask: 1,
  orderReceiveTimeout: 1,

  orderPickupTimeout: 1,
  orderShipperReceiveTimeout: 1,
  orderDeliveryException: 3,

  orderCanceled: 1,
  orderCancelApply: 3,
  orderRefundApply: 3,

  afsOrderShipperReceiveTimeout: 1,
  afsOrderDeliveryException: 3,
}

interface Reminder {
  enable: boolean,
  remindType: 'voice'|'vibrate' | 'voiceAndVibrate'
  listeningAfterSetting: boolean,
  voiceStyle: 'default'|'male',
  playTimes: PlayTimes
}
export const useReminderStore = defineStore('reminderStore', {
  state: (): Reminder => ({
    enable: true,
    remindType:'voice',
    listeningAfterSetting: false,
    voiceStyle: 'default',
    playTimes: {
      newOrder: 3,
      newPreOrder: 1,
      newPickupTask: 1,
      newReviewTask: 1,
      orderReceiveTimeout: 1,

      orderPickupTimeout: 1,
      orderShipperReceiveTimeout: 1,
      orderDeliveryException: 3,

      orderCanceled: 1,
      orderCancelApply: 3,
      orderRefundApply: 3,

      afsOrderShipperReceiveTimeout: 1,
      afsOrderDeliveryException: 3,
    }
  }),
  actions: {
    setEnable(enable: boolean) {
      this.enable = enable;
    },
    setVoiceStyle(voiceStyle: Reminder['voiceStyle']) {
      this.voiceStyle = voiceStyle;
    },
    setPlayTimes(playTimes: PlayTimes) {
      this.playTimes = playTimes;
    },
  },
  persist: {
    storage: persistLocalstorage
  }
});